#!/bin/bash
# 检查业务状态
HAPROXY_STATUS=`ps -C haproxy --no-header | wc -l`
if [ $HAPROXY_STATUS -eq 0 ];then
        # 尝试重启
        /etc/init.d/haproxy start
        sleep 3
        # 再次检查业务状态
        if [ `ps -C haproxy --no-header | wc -l` -eq 0 ];then
                # 停止keepalived
                /etc/init.d/keepalived stop
                # 写入DOWN表示keepalived停止
                echo "DOWN" > /etc/keepalived/keepalived_status.log
        fi
fi
